<?php
//+---------------------------------------------------------------------------------------------------------------------
//| 人生是荒芜的旅行，冷暖自知，苦乐在心
//+---------------------------------------------------------------------------------------------------------------------
//| Author:Janmas <janmas@126.com>
//+---------------------------------------------------------------------------------------------------------------------
//| 
//+---------------------------------------------------------------------------------------------------------------------


namespace app\common\command;


use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\Exception;
use think\facade\Log;

/**
 * 创建后台controller、service、model、view
 * @package app\common\command
 */
class Create extends Command
{
	protected function configure()
	{
		$this->setName('create')
			->addArgument('module', Argument::OPTIONAL, "模块名")
			->addArgument('name', Argument::OPTIONAL, "控制器名")
//			->addArgument('deep', Argument::OPTIONAL, "创建层数 cmvsw  c-controller m-model v-validate s-service w-view")
			->setDescription('创建指定的控制器、模型、service、validate以及视图 ');
	}

	protected function execute(Input $input, Output $output)
	{
		$module = trim($input->getArgument('module'));
		$name = trim($input->getArgument('name'));
//		$deep = trim($input->getArgument('deep'));
        $create = (new \helper\assistant\Create($module, $name));
        $create->controller()->model()->validate()->service()->view();
        $output->writeln('success');
       /* exit;
        if(empty($deep)){
			$create->controller()->model()->validate()->service()->view();
            $output->writeln('success');
            exit;
		}
		for($i=0;$i<strlen($deep);$i++){
			switch($deep{$i}){
				case 'c':
					$create->controller();
					break;
				case 'm':
					$create->model();
					break;
				case 'v':
					$create->validate();
					break;
				case 's':
					$create->service();
					break;
				case 'w':
					$create->view();
					break;
				default:
					throw new Exception('异常');
			}
		}
        $output->writeln('success');*/
	}
}